package pilgun.eshop.domain;

public class Item {
    private int id;
    private String name;
    private String category;
	private String description;
    private double price;
    private int stock;
    
    
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCategory() {
        return category;
    }
    public void setCategory(String category) {
        this.category = category;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public int getStock() {
        return stock;
    }
    public void setStock(int stock) {
        this.stock = stock;
    }
    @Override
    public String toString(){
        return " id: "+id+" name: "+name+" description: "+description+" category: "+category+" price: "+price+" count: "+stock;
    }
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((category == null) ? 0 : category.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		long temp;
		temp = Double.doubleToLongBits(price);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		Item other = (Item) obj;
		if (category == null) {
			if (other.category != null){
				return false;
			}
		}else{
			if (!category.equals(other.category)){
				return false;
			}
		}
		if (description == null) {
			if (other.description != null){
				return false;
			}
		}else{ 
			if (!description.equals(other.description)){
				return false;
			}
		}
		if (name == null) {
			if (other.name != null){
				return false;
			}
		}else{
			if (!name.equals(other.name)){
				return false;
			}
		}
		if (Double.doubleToLongBits(price) != Double
				.doubleToLongBits(other.price)){
			return false;
		}
		return true;
	}
	
}
